<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=640px,user-scalable=no,target-densitydpi=device-dpi" />
		<link rel="stylesheet" href="../css/css.css" type="text/css" />
		<script type="text/javascript" src='../js/jquery.min.js'></script>
		<script type="text/javascript" src='../js/main_in.js'></script>
		<script type="text/javascript" src='../js/common.js'></script>
		<title>客户新增</title>
		<script type="text/javascript">
			var uid = window.localStorage["uid"];
			var loginname = window.localStorage["loginname"];
               
               function doadd(){
               		var d = new Date();
                   var str = '';
                    str += d.getFullYear()+'-';
                    str  += d.getMonth() + 1+'-';
                    str  += d.getDate()+'';
                    str += ' ';
                    str += d.getHours()+':'; 
                    str  += d.getMinutes()+':'; 
                   str+= d.getSeconds()+''; 
                   
                   var Name = $("#passenger_fullname").val();
                   var ContactTel = $("#passenger_tel").val();
                   var Contact = $("#passenger_contact").val();
                   var CityID = $("#sub_cityid").val();
                   var CityName  = $("#CityName").val();
                   var Address = $("#Address").val();
                   
                   if(Name == ''){
                       alert("客户名称不能为空");
                        return false;
                   }
                   
                   if(CityName == ''){
                       alert("客户地址不能为空");
                        return false;
                   }
                   
                   if(Address == ''){
                       alert("详细地址不能为空");
                        return false;
                   }
                   
                   if(Contact == ''){
                       alert("联系人不能为空");
                        return false;
                   }
                   
                   if(ContactTel == ''){
                       alert("联系方式不能为空");
                        return false;
                   }
                   
                   
                   var body = {
                       "Type":"10","Name":Name,"Tel":'',"NDID":"63599-70527","Email":"","Fax":"","Contact":Contact,"ContactTel":ContactTel,"Sales":"","InvoiceType":"10","Remark":"","Img":"","CPID":"11583-47254","Token":"22e8f734-dae9-494e-a743-4c4a64af4ce2",
                       "Users":{"id": uid ,"username":loginname,"cpid":"11583-47254","cpname":"\u5361\u822a\u7f51\u7edc","ndid":"63599-70527","ndname":"\u5361\u822a\u7f51\u7edc","cmid":""},
                       "CityID": CityID,"CityName":CityName,"Address":Address,"CreateOn":str,"CreateBy":loginname,
                   }
                   
                   if(confirm("确认提交？")){
                   		var wt=plus.nativeUI.showWaiting();
                        $.ajax({
                            url: "http://api.unair.cn/api/CustomerBL",
                            type: "POST",
                            data: body,
                            success: function (data) {
                            	wt.close();
                                if(data != null){
                                    var w=plus.nativeUI.showWaiting("提交成功");
									w.onclose=function(){
										clearInterval(t);
									}
									var t=setInterval(function(){
										w.setTitle("提交成功");
										w.close();
										clicked("addr_search.html?x=1");
										clearInterval(t);
									},2000);
                                }else{
                                    alert("提交失败")
                                }
                            },
                            error: function (data) {
                            	wt.close();
                                alert(JSON.stringify(data));
                            }

                        });
                    };
               }
		</script>
	</head>
	<body>
		<div class="app_head">
            <div class="app_prev bg_back" onclick="back()"><img src="../img/arrow.png" /></div>
            <div class="app_head_text">客户新增</div>
            <div class="app_prev"></div>
        </div>
        <div class="app_body">
            <div class="main_in_input">
                <div class="main_in_input_text_left">客户名称：</div>
                <div class="main_in_input_input_right"><input type="text" id="passenger_fullname" value="" /></div>
            </div>
            <div class="main_in_input">
                <div class="main_in_input_text_left">客户地址：</div>
                <div class="main_in_input_input_right"><input type="text" class="select_city" id="CityName" value="" readonly="true" /></div>
                <input type="hidden" name="CityID" class="select_city_id" id="sub_cityid" />
            </div>
            <div class="main_in_input">
                <div class="main_in_input_text_left">详细地址：</div>
                <div class="main_in_input_input_right"><input type="text" id="Address" value="" /></div>
            </div>
            <div class="main_in_input">
                <div class="main_in_input_text_left">联系人：</div>
                <div class="main_in_input_input_right"><input type="text" id="passenger_contact" value="" /></div>
            </div>
            <div class="main_in_input">
                <div class="main_in_input_text_left">联系电话：</div>
                <div class="main_in_input_input_right"><input type="text" id="passenger_tel" value="" /></div>
            </div>
            <div style="background: #fff;width: 100%;height: 100px;">
                <div class="bg_submit" onclick="doadd()">提&nbsp;交</div>
                <div class="bg_back bg_back_class"  onclick="back()">取&nbsp;消</div>
            </div>
        </div>
        
<div class="outside_pull"></div>
<img src="../img/loading.gif" class="fade_out_img" id="fade_out_loading" />
	</body>
</html>
